package com.intct.util;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * @author gufg
 * @since 2025-07-28 16:27
 */
public class RedisUtil {
    private static JedisPool jedisPool = null;

    static {
        GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
        poolConfig.setMaxTotal(1000);
        poolConfig.setMaxIdle(100);
        poolConfig.setMinIdle(10);
        jedisPool = new JedisPool(poolConfig, "cdh-node", 16379, 2000, "Test_090110");
    }

    public static Jedis getConnection() {
        return jedisPool.getResource();
    }

    public static void closeConnection(Jedis jedis) {
        if (jedis != null) {
            jedis.close();
        }

    }
}
